package com.sino.androiddesign.anim.objectanimator

import android.animation.TypeEvaluator
import android.util.Log

//any 相当于 object
class PointEvaluator:TypeEvaluator<Any>{
    //复写 evaluate()
    // 在 evaluate()里写入对象动画过渡的逻辑
    override fun evaluate(fraction: Float, startValue: Any?, endValue: Any?): Any {


        //将动画的初始值和结束值 装换成point对象
        val startPoint = startValue as Point
        val endPoint = endValue as Point

        //根据fraction 来计算当前动画的x和y的值
        val x:Float = startPoint.x +fraction*(endPoint.x - startPoint.x)
        val y:Float = startPoint.y+fraction*(endPoint.y -startPoint.y)

        Log.e("fra","$fraction => $x ==> $y")
        return Point(x,y)

    }


}